package com.richapp.launcher.database.system.dao;

import android.content.Context;
import android.util.Log;

import com.j256.ormlite.stmt.QueryBuilder;
import com.richapp.launcher.database.system.SystemBaseDao;
import com.richapp.launcher.database.system.mode.BoxScreen;

import java.util.ArrayList;
import java.util.List;

public class BoxScreenDao extends SystemBaseDao<BoxScreen>{

	public BoxScreenDao(Context context) {
		super(context,BoxScreen.class);
	}

	public List<BoxScreen> getTopList(long topNumber){
		List<BoxScreen> boxScreenList = new ArrayList<BoxScreen>();
		try {
			QueryBuilder queryBuilder = gettOp().queryBuilder();
			queryBuilder.orderBy("createTime",false);
			queryBuilder.limit(topNumber);
			List<Object> objList = queryBuilder.query();
			for(Object obj : objList){
				if(obj != null){
					if(obj instanceof BoxScreen){
						boxScreenList.add((BoxScreen)obj);
					}
				}
			}
		}catch (Exception e){
			Log.e(getClass().getName(), e.getMessage());
		}
		return boxScreenList;
	}

}
